package entities;

import java.io.Serializable;
import java.util.List;

import javax.persistence.*;

/**
 * The persistent class for the employee database table.
 * 
 */
@Entity
@Table(name = "employee")
public class Employee implements Serializable {
	private static final long serialVersionUID = 1L;
	private int idEmployee;
	private String address;
	private String emgContact;
	private String firstName;
	private User user;
	private String lastName;
	private List<Doctor> doctors;

	public Employee() {
	}

	public Employee(String address, String emgContact, String firstName,
			User user, String lastName) {
		super();
		this.address = address;
		this.emgContact = emgContact;
		this.firstName = firstName;
		this.user = user;
		this.lastName = lastName;
	}

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(unique=true, nullable=false)
	public int getIdEmployee() {
		return this.idEmployee;
	}

	public void setIdEmployee(int idEmployee) {
		this.idEmployee = idEmployee;
	}

	@Column(nullable = false, length = 200)
	public String getAddress() {
		return this.address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	@Column(length = 200)
	public String getEmgContact() {
		return this.emgContact;
	}

	public void setEmgContact(String emgContact) {
		this.emgContact = emgContact;
	}

	@Column(nullable = false, length = 50)
	public String getFirstName() {
		return this.firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	@ManyToOne
	@JoinColumn(name = "idUser", nullable = false)
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@Column(nullable = false, length = 50)
	public String getLastName() {
		return this.lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}
	

// bi-directional many-to-one association to LabServiceDetail
	@OneToMany(mappedBy = "employee", fetch = FetchType.EAGER)
	public List<Doctor> getDoctors() {
		return this.doctors;
	}

	public void setDoctors(List<Doctor> doctors) {
		this.doctors = doctors;
	}

	@Override
	public String toString() {
		return this.getClass().getName() + "[ " + idEmployee + " | " + address
				+ " | " + emgContact + " | " + firstName + " | " + lastName
				+ " | " + user.getIdUser() + " ]";
	}

}